<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
	<style type="text/css">
		.display{
			width: 300px;
			height: 200px;
			background: lightgray;
		}
	</style>
</head>
<body>
	<ul id="display">
		
	</ul>
	<div>
		<input type="text" name="user" id='user'>
		<input type="button" value='提交' onclick="submit()">
	</div>
	<script type="text/javascript">
		let socket = io.connect('http://192.168.1.62:8080/');
		let user=document.getElementById('user')
		let display=document.getElementById('display')
		function submit(){
		  socket.emit('submit',user.value)
		  user.value=''
		}
		socket.on('news', function (data) {
			let li=document.createElement("li")
			li.innerText=data
		  display.appendChild(li)
		});
	</script>
</body>
</html>